//
//  HomeListViewController.m
//  FoodCorner
//
//  Created by Summer on 16/2/29.
//  Copyright © 2016年 zhangchao. All rights reserved.
//

#import "HomeListViewController.h"
#import "MainListModel.h"
#import "ImageArrayModel.h"
#import <SDAutoLayout/UIView+SDAutoLayout.h>
#import <SDWebImage/UIImageView+WebCache.h>
@interface HomeListViewController ()
@property (nonatomic,strong) UIImageView *stepImgView;
@property (nonatomic,strong) UILabel *stepTextLab;
@property (nonatomic,strong) UITapGestureRecognizer *tapGesture;
@end

@implementation HomeListViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    [self viewBlurEffect];
    [self stepDetailed];
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc]initWithBarButtonSystemItem:(UIBarButtonSystemItemStop) target:self action:@selector(clickBackButtonAciotn)];
    self.tapGesture = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(clickBackButtonAciotn)];
    _tapGesture.numberOfTapsRequired=1;//设置点按次数，默认为1，注意在iOS中很少用双击操作
    _tapGesture.numberOfTouchesRequired=1;//点按的手指数
    //添加手势到对象(注意，这里添加到了控制器视图中，而不是图片上，否则点击空白无法隐藏导航栏)
    [self.view addGestureRecognizer:_tapGesture];

}
- (void)clickBackButtonAciotn
{
    [self dismissViewControllerAnimated:YES completion:nil];
}
#pragma mark ----添加视图模糊效果，增加视觉效果
/*
- (void)viewBlurEffect
{
    UIImageView  *backgroudImage = [[UIImageView alloc]initWithFrame:[UIScreen mainScreen].bounds];
    backgroudImage.image  = [UIImage imageNamed:@"placeholder"];
    [self.view addSubview:backgroudImage];
    UIVisualEffectView *backgroundView = [[UIVisualEffectView alloc]initWithEffect:[UIBlurEffect effectWithStyle:UIBlurEffectStyleLight]];
    backgroundView.alpha = 0.9;
    backgroundView.frame = self.view.bounds;
    [self.view addSubview:backgroundView];

}
*/
#pragma mark ----页面主要的一个步骤的主要详情做法
- (void)stepDetailed
{
    [self.stepImgView sd_setImageWithURL:[NSURL URLWithString:self.dishMdoel.img] placeholderImage:[UIImage imageNamed:@"placeholder"] options:(SDWebImageRefreshCached)];
    self.stepTextLab.text = self.dishMdoel.step;
    [self.view addSubview: self.stepImgView];
    [self.view addSubview:self.stepTextLab];
    self.stepImgView.sd_layout
    .centerXEqualToView(self.view)
    .centerYIs(self.view.center.y - 50)
    .widthRatioToView(self.view,0.8)
    .heightEqualToWidth();
    self.stepTextLab.sd_layout
    .topSpaceToView(self.stepImgView,10)
    .leftSpaceToView(self.view,10)
    .rightSpaceToView(self.view,10)
    .autoHeightRatio(0);

    
}
///懒加载图片，如果没有图片不会加载
-(UIImageView *)stepImgView
{
    if (!_stepImgView) {
        _stepImgView = [UIImageView new];
        _stepImgView.layer.masksToBounds = YES;
        _stepImgView.layer.cornerRadius = self.view.bounds.size.width * 0.8 / 2;
    }
    return _stepImgView;
}
///懒加载文字，如果没有文字不会加载
-(UILabel *)stepTextLab
{
    if (!_stepTextLab) {
        _stepTextLab = [UILabel new];
        _stepTextLab.textAlignment = NSTextAlignmentCenter;
        _stepTextLab.numberOfLines = 0;
    }
    return _stepTextLab;
}
#pragma mark ----添加视图模糊效果，增加视觉效果
- (void)viewBlurEffect
{
    UIImageView *imageView = [[UIImageView alloc]initWithFrame:self.view.bounds];
    imageView.image = [UIImage imageNamed:@"placeholder"];
    //毛玻璃效果
    UIVisualEffectView *visualView =[[UIVisualEffectView alloc]initWithEffect:[UIBlurEffect effectWithStyle:(UIBlurEffectStyleLight)]];
    visualView.alpha = 0.9;
    visualView.frame=[UIScreen mainScreen].bounds;
    [imageView addSubview:visualView];
    [self.view addSubview:imageView];
}

@end
